import request from '@/utils/request'

// 获取所有工作项
export function getAllWorkItems() {
  return request({
    url: '/api/workitems',
    method: 'get'
  })
}

// 根据项目ID获取工作项
export function getWorkItemsByProjectId(projectId) {
  return request({
    url: `/api/workitems/project/${projectId}`,
    method: 'get'
  })
}

// 根据ID获取工作项详情
export function getWorkItemById(id) {
  return request({
    url: `/api/workitems/${id}`,
    method: 'get'
  })
}

// 创建工作项
export function createWorkItem(data) {
  return request({
    url: '/api/workitems',
    method: 'post',
    data
  })
}

// 更新工作项
export function updateWorkItem(id, data) {
  return request({
    url: `/api/workitems/${id}`,
    method: 'put',
    data
  })
}

// 删除工作项
export function deleteWorkItem(id) {
  return request({
    url: `/api/workitems/${id}`,
    method: 'delete'
  })
}

// 根据状态获取工作项
export function getWorkItemsByStatus(status) {
  return request({
    url: `/api/workitems/status/${status}`,
    method: 'get'
  })
}

// 根据负责人获取工作项
export function getWorkItemsByResponsiblePerson(responsiblePerson) {
  return request({
    url: `/api/workitems/assignee/${responsiblePerson}`,
    method: 'get'
  })
}